// 电商产品数据 API
export default defineEventHandler(async (event) => {
  // 模拟网络延迟
  const query = getQuery(event)
  const delay = query.delay ? Number(query.delay) : 0
  
  if (delay > 0) {
    await new Promise(resolve => setTimeout(resolve, delay))
  }

  // 模拟产品数据
  const products = [
    {
      id: 1,
      name: '高端无线耳机 Pro Max',
      price: 1299,
      originalPrice: 1999,
      image: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop',
      rating: 4.8,
      sales: 12580,
      tag: '热销'
    },
    {
      id: 2,
      name: '智能手表运动版',
      price: 899,
      originalPrice: 1299,
      image: 'https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=400&h=400&fit=crop',
      rating: 4.6,
      sales: 8920,
      tag: '新品'
    },
    {
      id: 3,
      name: '机械键盘 RGB 青轴',
      price: 599,
      originalPrice: 799,
      image: 'https://images.unsplash.com/photo-1587829741301-dc798b83add3?w=400&h=400&fit=crop',
      rating: 4.9,
      sales: 15670,
      tag: '爆款'
    },
    {
      id: 4,
      name: '4K 高清摄像头',
      price: 799,
      originalPrice: 1199,
      image: 'https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?w=400&h=400&fit=crop',
      rating: 4.7,
      sales: 6540,
      tag: '热销'
    },
    {
      id: 5,
      name: '游戏鼠标电竞版',
      price: 299,
      originalPrice: 499,
      image: 'https://images.unsplash.com/photo-1527814050087-3793815479db?w=400&h=400&fit=crop',
      rating: 4.5,
      sales: 9830,
      tag: '限时'
    },
    {
      id: 6,
      name: '便携蓝牙音箱',
      price: 399,
      originalPrice: 599,
      image: 'https://images.unsplash.com/photo-1608043152269-423dbba4e7e1?w=400&h=400&fit=crop',
      rating: 4.6,
      sales: 7240,
      tag: '新品'
    },
    {
      id: 7,
      name: 'Type-C 数据线 3米',
      price: 49,
      originalPrice: 99,
      image: 'https://images.unsplash.com/photo-1583863788434-e58a36330cf0?w=400&h=400&fit=crop',
      rating: 4.8,
      sales: 23450,
      tag: '爆款'
    },
    {
      id: 8,
      name: '笔记本电脑支架',
      price: 159,
      originalPrice: 259,
      image: 'https://images.unsplash.com/photo-1527864550417-7fd91fc51a46?w=400&h=400&fit=crop',
      rating: 4.7,
      sales: 5620,
      tag: '热销'
    }
  ]

  return {
    success: true,
    data: products,
    total: products.length,
    timestamp: new Date().toISOString()
  }
})

